package com.java.simple.study.juc.p2;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @author zhoujunlin
 * @date 2022年04月05日 17:41
 * @desc
 */
@Slf4j(topic = "c.ThreadStarter")
public class ThreadStarter {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        Thread t1 = new Thread("t1") {
            @Override
            public void run() {
                log.debug("hello");
            }
        };
        t1.start();

        Runnable task = () -> log.debug("hello");
        Thread t2 = new Thread(task, "t2");
        t2.start();

        FutureTask<Integer> task3 = new FutureTask<>(() -> {
            log.debug("hello");
            return 100;
        });
        Thread t3 = new Thread(task3, "t3");
        t3.start();

        Integer result = task3.get();
        log.debug("结果是：{}", result);
    }


}
